package bs.app.Client;

import bs.app.Main.CCanvas;
import bs.app.Position.CPosition;
import bs.app.Res.CRess;
import bs.app.android.Graphics;
import bs.app.android.Image;

public class isChangeLoadingState
{
	public int indexloading;
	public static Image imgtransparent = null;
	public int HeightImage=273;
    public int timeForLoading = 50;
    public int x,y;
    public int delaytime;
    public int time;
    public static final int fixtime=60;
	public isChangeLoadingState()
	{
		CRess.ImgLoading();
		createImage();
		x=0;
		y=25;
		time=fixtime;
	}
	public void createImage()
	{
//		Image buffer;
//		buffer=Image.createImage(CCanvas.s_iWcanvas,CCanvas.s_iHcanvas);
//		Graphics g = buffer.getGraphics();
//		int[] data=new int[CCanvas.s_iWcanvas * CCanvas.s_iHcanvas];
//		buffer.getRGB(data, 0, CCanvas.s_iWcanvas, 0, 0, CCanvas.s_iWcanvas,CCanvas.s_iHcanvas);
//		for(int i=0;i<data.length;i++)
//		{
//			data[i] = 0x09000000;
//		}
//		imgtransparent=Image.createRGBImage(data, CCanvas.s_iWcanvas, CCanvas.s_iHcanvas, true);
	}
	public void paintMenuBar(Graphics g){
		if(CCanvas.s_iWcanvas > CRess.menubar.getWidth()){
			g.drawImage(CRess.menubar, 0, CCanvas.s_iHcanvas, CPosition.ANCHOR_LEFT_BOTTOM);
			for(int i = CRess.menubar.getWidth(); i < CCanvas.s_iWcanvas + CRess.footer_back.getWidth(); i+=CRess.footer_back.getWidth())
				g.drawImage(CRess.footer_back, i, CCanvas.s_iHcanvas, CPosition.ANCHOR_LEFT_BOTTOM);

		}else{
			g.drawImage(CRess.menubar, 0, CCanvas.s_iHcanvas, CPosition.ANCHOR_LEFT_BOTTOM);

		}
	}
	public void paint(Graphics g)
	{
		paintMenuBar(g);
		g.drawImage(CRess.imgloading[indexloading], CCanvas.s_iWcanvas>>1, CCanvas.s_iHcanvas>>1, CPosition.ANCHOR_HCENTER_VCENTER);
	}
	public void painttransparent(Graphics g)
	{
//		g.drawImage(imgtransparent, CCanvas.xTranslate+x, CCanvas.yTranslate+y, Graphics.TOP|Graphics.LEFT);		
		g.fillColor(x, y, CCanvas.s_iWcanvas, CCanvas.s_iHcanvas, 0x0F000000);
	}
	public void pointerPressed(int px,int py)
	{
		if(CCanvas.isPointerPressed) //  User PointerPressed
		{
			
		}
		CCanvas.resetPointerPress();  // User PointerReleased
	}
	public void UpdateKeyPress(boolean[]keyPressed,boolean[]keyHold,int currentAsccii[])
	{
		update();
	}
	
	public void update()
	{
		indexloading++;
		if(indexloading>CRess.imgloading.length-1)
		{
			indexloading=0;
		}
		////////////  reset status
		delaytime++;
		if(delaytime>20)
		{
			time--;
			if(time<=0)
			{
				CCanvas.CurrentScreen=CCanvas.SaveStatePrevious;
			}
			delaytime=0;
		}
	}
}
